import { formatTimestamp } from "../utils/time";

// 定义文本信息接口
interface TextInfo {
  vno: string;
  gtime: string;
  speed: number;
  lon: number;
  lat: number;
}

// 定义位置坐标类型
type Position = [number, number];

// 定义函数参数接口
interface GetInfoWindowTemplateParams {
  text: TextInfo;
  position: Position;
}

interface Params {
  searchInfo: any;
  e: GetInfoWindowTemplateParams;
}

export const getInfoWindowTemplate = ({ searchInfo, e: { text } }: Params): string => {
  return `
    <div style="width: 400px; background-color: #fff; color: #606262; font-size: 14px">
      <div style="display: flex; justify-content: space-between; align-items: center; padding: 10px; background-color: #C0C4CC">
        <span>${searchInfo.value.vno}</span>
        <span style="cursor: pointer" onclick="window.closeInfoWindow()">关闭</span>
      </div>
      <div style="padding: 10px">
        <div style="line-height: 3">
          上报时间:
          <span style="color: #97a8be">${formatTimestamp(text.gtime)}</span>
        </div>
        <div style="line-height: 3">
          速度:
          <span style="color: #97a8be">${text.speed} km/h</span>
        </div>
        <div style="line-height: 3">
          当前位置:
          <span style="color: #97a8be"">
            ${text.lon}, ${text.lat}
          </span>
        </div>
      </div>
    </div>
  `;
};
